0.1 Make plots

perm <- c(1,2,3,4,5,10,6,7,8,9,11)
tight <- read.csv("collman14v2_F0_tight_annotations.csv")[perm]
stight <- scale(tight, center = TRUE, scale = TRUE)

ccol <- c('blue', 'blue', 'blue', 'red', 'red', 
          'red', 'red', 'darkgreen', 'darkgreen', 'darkgreen',  
          'darkgreen')

set.seed(317)
Lt <- runAll(sF0, ccol = ccol)
Lt[[1]] <- mlocation(F0, ccol = ccol)

w = 720
h = 720 

png("meda_plots_tight/d1heat.png", width = w, height = h)
p1 <- plot(Lc[[2]]) 
show(p1)
dev.off()

png("meda_plots_tight/mlocation.png", width = w, height = 0.5*h)
p1 <- plot(Lt[[1]]) 
show(p1)
dev.off()

png("meda_plots_tight/cumulativeVariance.png", width = w, height = h)
p1 <- plot(Lt[[3]]) 
show(p1)
dev.off()

png("meda_plots_tight/outliers.png", width = w, height = h)
p1 <- plot(Lt[[4]]) 
show(p1)
dev.off()

png("meda_plots_tight/cor.png", width = w, height = h)
plot(Lt[[6]]) 
dev.off()

png("meda_plots_tight/pairhexTight.png", width = 2*w, height = 2*h)
pairhex(stight)
dev.off()


png("meda_plots_tight/hmcClassificationsTight.png", width = 2*w, height = 2*h)
cr <- viridis(max(Lt[[7]]$dat$labels$col))
pairs(Lt[[7]]$dat$data, pch = 19, cex = 0.5, col = cr[Lt[[7]]$dat$labels$col])
dev.off()


png("meda_plots_tight/dendrograms.png", width = w, height = h)
plotDend(Lt[[7]])
dev.off()

png("meda_plots_tight/stackMeans.png", width = w, height = 2*h)
p1 <- stackM(Lt[[7]], ccol = ccol, depth = 3, centered = TRUE)
show(p1)
dev.off()

png("meda_plots_tight/clusterMeans.png", width = w, height = h)
p1 <- clusterMeans(Lt[[7]], ccol = ccol)
show(p1)
dev.off()
loc <- h5read(f, name = "Locations")
c1 <- closestK(Lt[[7]], K = 1, locs = loc)
c5 <- closestK(Lt[[7]], K = 5, locs = loc)

C1 <- Reduce(rbind, c1)
C5 <- Reduce(rbind, c5)
rownames(C1) <- NULL
rownames(C5) <- NULL
C1
#C5
f <- 'collman14v2_annotationCubes.csv.h5'
F0 <- h5read(f, name = "F0")
loc <- h5read(f, name = "Locations")
chan <- h5read(f, name = "Channels")
colnames(F0) <- chan
sF0 <- scale(F0, center = TRUE, scale = TRUE)

ccol <- c('blue', 'blue', 'blue', 'red', 'red', 
          'red', 'red', 'darkgreen', 'darkgreen', 'darkgreen', 
          'darkgreen')

set.seed(317)
Lc <- runAll(sF0, ccol = ccol)
Lc[[1]] <- mlocation(F0, ccol = ccol)

w = 720
h = 720 

png("meda_plots_cubes/d1heat.png", width = w, height = h)
p1 <- plot(Lc[[2]]) 
show(p1)
dev.off()

png("meda_plots_cubes/mlocation.png", width = w, height = 0.5*h)
p1 <- plot(Lc[[1]]) 
show(p1)
dev.off()

png("meda_plots_cubes/cumulativeVariance.png", width = w, height = h)
p1 <- plot(Lc[[3]]) 
show(p1)
dev.off()

png("meda_plots_cubes/outliers.png", width = w, height = h)
p1 <- plot(Lc[[4]]) 
show(p1)
dev.off()

png("meda_plots_cubes/cor.png", width = w, height = h)
plot(Lc[[6]]) 
dev.off()

png("meda_plots_cubes/pairhex.png", width = 2*w, height = 2*h)
pairhex(sF0)
dev.off()


png("meda_plots_cubes/hmcClassifications.png", width = 2*w, height = 2*h)
cr <- viridis(max(Lc[[7]]$dat$labels$col))
pairs(Lc[[7]]$dat$data, pch = 19, cex = 0.5, col = cr[Lc[[7]]$dat$labels$col])
dev.off()


png("meda_plots_cubes/dendrograms.png", width = w, height = h)
plotDend(Lc[[7]])
dev.off()

png("meda_plots_cubes/stackMeans.png", width = w, height = 2*h)
p1 <- stackM(Lc[[7]], ccol = ccol, depth = 3, centered = TRUE)
show(p1)
dev.off()

png("meda_plots_cubes/clusterMeans.png", width = w, height = h)
p1 <- clusterMeans(Lc[[7]], ccol = ccol)
show(p1)
dev.off()

1 Tight F0 plots

1.1 1-d Heatmap

1.2 Location meda_plots

1.3 Outliers as given by randomForest

1.4 Correlation Matrix

1.5 Cumulative Variance with Elbows

1.6 Paired Hex-binned plot

1.7 Hierarchical GMM Classifications

1.8 Hierarchical GMM Dendrogram

1.9 Stacked Means

1.10 Cluster Means

2 Half micron cube F0 plots

2.1 1-d Heatmap

2.2 Location meda_plots

2.3 Outliers as given by randomForest

2.4 Correlation Matrix

2.5 Cumulative Variance with Elbows

2.6 Paired Hex-binned plot

2.7 Hierarchical GMM Classifications

2.8 Hierarchical GMM Dendrogram

2.9 Stacked Means

2.10 Cluster Means